'use strict'

const { Sequelize ,Op}=require('sequelize');
const tool=require('../tool/filters');

const sequelize=new Sequelize('library','postgres','whr0625.',{
    host:'host.wuhuqf.top',
    dialect:'postgres',
})

let resObj={};

resObj.Op=Op;

let resFiles=tool(__dirname);

resFiles.forEach(item=>{
    let modelName=item.replace('.js','');
    let tableName=modelName.toLowerCase();

    let tmpObj=require(__dirname+'/'+item);

    resObj[modelName]=sequelize.define(tableName,tmpObj);
})

resObj.sync=async ()=>{
    sequelize.sync({force:true});
}

module.exports=resObj;